//
//  JuDelegate.swift
//  JuSwift
//
//  Created by Juvid on 2018/4/23.
//  Copyright © 2018年 Juvid. All rights reserved.
//

import UIKit
//继承于class是因为只有继承于class才能用weak来修饰代理
public protocol JuProtocol : class {
//属性，set表示可写，get可写
    var juName : String {get set}
//方法
    func juTestDelegage()

    func juExtension()

//    @objc optional func juOptional()
}
public protocol JuProtocol2 {

}

class JuDelegate: NSObject {
  weak open var delegate: JuProtocol?
    func juHandle() {
        delegate?.juTestDelegage()
        delegate?.juExtension()
        delegate?.juName = "我来赋值"
        print(delegate?.juName ?? "没有值")
    }
}

class JuProgate: JuProtocol  {
    var juName: String = ""
    
    func juStart()  {
        let testPro = JuDelegate.init()
        testPro.delegate = self
        testPro.juHandle()
    }
    
    func juTestDelegage() {
        NSLog("代理回调")
    }
//    JuCategory中已实现拓展可以不写
    func juExtension() {
        print("类中实现协议")
    }
}
